<template>
    <div>
        <j-modal
            :title="title"
            :width="width"
            :visible="visible"
            switchFullscreen
            @ok="handleOk"
            :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
            @cancel="handleCancel"
            cancelText="关闭">
            <a-form layout="inline">
                <a-row>
                    <a-col v-if="code==1">
                        <a-form-item label="答辩时间：">
                            <!-- <a-input placeholder="请选择答辩时间"></a-input> -->
                            <!-- <a-date-picker v-model="cxjFssjId"/> -->
                            <a-select class="defenseTime" v-model="cxjFssjId" placeholder="请选择答辩时间">
                                <a-select-option v-for="(item, index) in dataSource" :key="index" :value="item.id">{{item.fsSjRq}}</a-select-option>
                            </a-select>
                        </a-form-item>
                    </a-col>
                    <a-col v-else-if="code==2">
                        <a-form-item label="答辩序号：">
                            <a-input class="defenseNumber" placeholder="请填写答辩序号" v-model="xh"></a-input>
                        </a-form-item>
                    </a-col>
                    <a-col v-else-if="code==3">
                         <a-form-item label="主审专家：">
                            <!-- <a-input placeholder="请选择主审专家"></a-input> -->
                            <a-select class="leadReviewer" v-model="zjid" placeholder="请选择主审专家">
                                <a-select-option v-for="(item, index) in expertList" :key="index" :value="item.id">{{item.zj_xm}}</a-select-option>
                            </a-select>
                        </a-form-item>
                     </a-col>
                </a-row>
            </a-form>
        </j-modal>
    </div>
</template>

<script>
import { getAction } from '@/api/manage';

import moment from 'moment'
export default {
    name: "CxjJsfsFpCgUpdate",
    props: ['code','flag','fsfzid','fzxmid'],
    data(){
        return {
            visible: false,
            title:'',
            width: 800,
            disableSubmit: false,
            form: this.$form.createForm(this),
            labelCol: {
                xs: { span: 24 },
                sm: { span: 5 },
            },
            wrapperCol: {
                xs: { span: 24 },
                sm: { span: 16 },
            },
            expertList: [],
            zjid: '',
            cxjFssjId:'',
            xh: '',
            url: {
                list: "/cxj/cxjFsSj/cxjfs_dbsjlist"
            },
            dataSource: []
        }
    },
    watch: {
        flag(next, prev) {
            if (next != prev) {
                var self = this;
                self.visible = !self.visible;
                self.selectedExpertList();
                self.getDbTimeList();
                if (self.code == 1) {
                    self.title = "修改答辩时间"
                } else if (self.code == 2) {
                    self.title = "修改答辩序号"
                } else if (self.code == 3) {
                    self.title = '修改主审专家'
                }
            }
        }
    },
    methods: {
        moment,
        // 获取答辩时间
        getDbTimeList(){
            getAction(this.url.list,{shijian:moment(new Date()).format('YYYY')}).then((res) => {
                if (res.success) {
                    this.dataSource = res.result.records || res.result;
                }
                if (res.code === 510) {
                    this.$message.warning(res.message)
                }
            })
        },
        selectedExpertList(){
            this.selectedSpinning = true;
            let data = {
                csfzid: this.fsfzid
            }
            console.log(data)
            let that = this;
            let httpurl = "/cxj/cxjFsFzZj/cxjfs_fzzjlist_yx"
            getAction(httpurl,data).then((res)=>{
                if(res.success){
                    res.result.map(item=>{
                        item.selected = false;
                    })
                    this.expertList = res.result;
                }
            }).finally(() => {
                that.confirmLoading = false;
            })
        },
        handleCancel(){
            this.visible = false;
            this.xh = '';
            this.zjid = '';
            this.cxjFssjId = '';
        },
        handleOk(){
            let data = {
                fzxmid: this.fzxmid,
            }
            if (this.code == 1) {
                data.cxjFssjId = this.cxjFssjId;
            } else if (this.code == 2) {
                data.xh = this.xh;
            } else if (this.code == 3) {
                data.zjid = this.zjid;
            }
            this.$emit('handleUpdateCgInfo',data)
            console.log('参数',data)
        },
    }
}
</script>

<style scoped lang="less">
/deep/.leadReviewer, /deep/.defenseTime {
    width: 300px!important;
    .ant-select-selection {
        width: 300px!important;
    }
}
</style>